var listUrl = rootPath+'/manage/markingPaper/subjective';//列表
var markingHandleUrl = rootPath+'/manage/markingPaper/subjective/markingHandleUI?';//阅卷处理

$(function(){
	queryGradeByBatch();
	$('#query_batch').change(function(){
		queryGradeByBatch();
	});
	$('#query_grade').change(function(){
		queryCourseByGrade();
	});
	
	$('.btn-start').click(function(){
		location.href = markingHandleUrl + 'areaId='+$(this).parents('tr').attr('data-areaId');
	});
	$('.btn-restart').click(function(){
		layer.confirm('您确定要重新阅卷吗？', function(index) {
			location.href = markingHandleUrl + 'areaId='+$(this).parents('tr').attr('data-areaId');
		});
	});
	$('.btn-continue').click(function(){
		var areaId = $(this).parents('tr').attr('data-areaId');
		var current = $(this).parents('tr').attr('data-dyys');
		location.href = markingHandleUrl + 'areaId='+areaId+'&current='+current;
	});
});

//根据批次查询年级
var queryGradeByBatch = function(){
	common_ajax.ajax(rootPath+'/manage/courseTemplate/queryGradeByBatch', {batchId : $('#query_batch option:selected').val()}, 'json', function(data){
		if(data.list){
			var html = '<option value="">---请选择---</option>';
			$(data.list).each(function(index, item){
				html += '<option value="'+item.gradeNo+'"';
				if(item.gradeNo==query_grade){
					html += ' selected="selected"';
				}
				html += '>'+item.gradeName+'</option>';
			});
			$('#query_grade').html(html);
			queryCourseByGrade();
		}
	});
}
//根据年级查询课程
var queryCourseByGrade = function(){
	var batchId = $('#query_batch option:selected').val();
	var gradeNo = $('#query_grade option:selected').val();
	if(query_grade != null && query_course != null){
		batchId = query_grade;
		gradeNo = query_course;
	}
	common_ajax.ajax(rootPath+'/manage/courseTemplate/queryCourseByGrade', {batchId : batchId,gradeNo : gradeNo}, 'json', function(data){
		if(data.list){
			var html = '<option value="">---请选择---</option>';
			$(data.list).each(function(index, item){
				html += '<option value="'+item.courseNo+'"';
				if(item.courseNo==query_course){
					html += ' selected="selected"';
				}
				html += '>'+item.courseName+'</option>';
			});
			$('#query_course').html(html);
		}
	});
}

//刷新事件
function refreshBack(){
	location.href = listUrl;
}
